package com.lean.android.adsdk

import android.app.Application
import com.lean.android.ad.core.config.AdParamsProvider
import com.lean.android.ad.core.config.AppInfoProvider
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidFileProperties
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import org.koin.core.context.startKoin
import org.koin.dsl.module

class App : Application(), KoinComponent {

    private val adInitial by inject<AdInitial>()

    override fun onCreate() {
        super.onCreate()
        startKoin {
            androidContext(this@App)
            androidFileProperties("ad.properties")
            androidFileProperties("app_config.properties")

            val appModule = module {
                single { AdInitial() }
                single<AppInfoProvider> { AppInfoProviderImpl() }
                single<AdParamsProvider> { AdParamsProviderImpl() }
            }

            modules(appModule)
        }

        adInitial.init(this)

    }
}